﻿<?php
require_once dirname(__FILE__).'/CurrentClient.php';

session_start();

if(!isset($_SESSION[USER_ID_KEY]))
{
	$RedirectPageUri = "{$RootDirectoryUri}/Authentication/GoogleLogin.php";
	header( 'Location: '.$RedirectPageUri ) ;
	return;
}

// Google prilogino, bet vartotojo nėra mūsų bazėje
$CurrentClient = unserialize($_SESSION[USER_ID_KEY]);
if (!($CurrentClient->isActive && ($CurrentClient->isAdministrator || $CurrentClient->allRoles)))
{
	$RedirectPageUri = "{$RootDirectoryUri}/Authentication/GoogleLogin.php";
	header( 'Location: '.$RedirectPageUri ) ;
	return;
}

if ($CurrentClient->isActive && $CurrentClient->isAdministrator)
{
	$RedirectPageUri = "{$RootDirectoryUri}/AdminPage.php";
	header( 'Location: '.$RedirectPageUri ) ;
	return;
}
?>
